export function getIndexText(param) {
  const result = `
import React from 'react';
import { Icon, Grid } from 'antd-mobile';
import { StickyContainer } from 'react-sticky';
import StickyNav from 'components/StickyNav';
import { connect } from 'umi';

class App extends React.Component {
  constructor(props) {
    super(props);
  }

  componentDidMount() {}

  //  跳转对应子应用
  onClickApp = (param) => {
    console.log('param', param);
  };

  render() {
    const data = [
      {
        id: 'id1',
        icon: 'https://gw.alipayobjects.com/zos/rmsportal/nywPmnTAvTmLusPxHPSu.png',
        text: '专题',
      },
      {
        id: 'id1',
        icon: 'https://gw.alipayobjects.com/zos/rmsportal/nywPmnTAvTmLusPxHPSu.png',
        text: '专题',
      },
      {
        id: 'id1',
        icon: 'https://gw.alipayobjects.com/zos/rmsportal/nywPmnTAvTmLusPxHPSu.png',
        text: '专题',
      },
      {
        id: 'id1',
        icon: 'https://gw.alipayobjects.com/zos/rmsportal/nywPmnTAvTmLusPxHPSu.png',
        text: '专题',
      },
      {
        id: 'id1',
        icon: 'https://gw.alipayobjects.com/zos/rmsportal/nywPmnTAvTmLusPxHPSu.png',
        text: '专题',
      },
      {
        id: 'id1',
        icon: 'https://gw.alipayobjects.com/zos/rmsportal/nywPmnTAvTmLusPxHPSu.png',
        text: 'name',
      },
      {
        id: 'id1',
        icon: 'https://gw.alipayobjects.com/zos/rmsportal/nywPmnTAvTmLusPxHPSu.png',
        text: 'name',
      },
      {
        id: 'id1',
        icon: 'https://gw.alipayobjects.com/zos/rmsportal/nywPmnTAvTmLusPxHPSu.png',
        text: 'name',
      },
      {
        id: 'id1',
        icon: 'https://gw.alipayobjects.com/zos/rmsportal/nywPmnTAvTmLusPxHPSu.png',
        text: 'name',
      },
      {
        id: 'id1',
        icon: 'https://gw.alipayobjects.com/zos/rmsportal/nywPmnTAvTmLusPxHPSu.png',
        text: 'name',
      },
    ];

    return (
      <StickyContainer>
        <StickyNav
          title={'h5 管理'}
          mode="light"
          // icon={<Icon type="left"/>}
          onLeftClick={() => console.log('onLeftClick')}
        />

        {/*下拉列表*/}
        <Grid
          columnNum={3}
          onClick={this.onClickApp}
          data={data}
          activeStyle={false}
        />
      </StickyContainer>
    );
  }
}

export default connect(({ indexModel }) => ({
  indexModel,
}))(App);

  `;
  return result;
}

export function getServiceText(param) {
  const result = `

import request from '@/utils/request';
//
export async function getList(params: any) {
  return request('/api/expressList', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

  `;
  return result;
}

export function getModelText(param) {
  const result = `
import * as services from '../services';
const initTableState = {
  pageSize: 10,
  pageIndex: 1,
  total: 0,
  list: []
}

// modal 实现
const Model = {
  namespace: 'indexModel',
  state: {
    listObj: {
      ...initTableState
    },
  },

  reducers: {
    updateState(state, {res}) { // 更新state
      return {
        ...state,
        ...res,
      };
    },
  },
  effects: {
    // 获取当前用户
    * getData({payload, mTitle, service}, {call, put, select}) {
      const {data} = yield call(services[service], payload);
      if (data) {
        yield put({type: 'updateState', res: {[mTitle]: data}});
      }
      return data;
    },

  },
};

export default Model;
`;
  return result;
}
